public class Solution83 {
    public ListNode deleteDuplicates(ListNode head) {
        if (head == null || head.next == null) {
            return head;
        }
        ListNode cur = new ListNode();
        ListNode i = head;
        head = cur;
        while (i.next != null) {
            if (i.val != i.next.val) {
                cur.next = i;
                cur = i;
            }
            i = i.next;
        }
        cur.next = i;
        return head.next;
    }
}
